/**
    算法描述：
    核心问题：
    解决所需数据结构+算法：
**/
#include<bits/stdc++.h>
using namespace std;
int f[100010] = {0};
 
int findfa(int x) {
    return f[x] = f[x] == x ? x : findfa(f[x]);
}
 
int main() {
    int n, m, ans = 0;
    scanf("%d%d", &n, &m);
    for (int i=1; i<=n; i++)
        f[i] = i;
    while(m--) {
        int x, y;
        scanf("%d%d", &x, &y);
        int lx = findfa(x);
        int ly = findfa(y);
        f[lx] = ly;
    }
    for (int i=1; i<=n; i++)
        if (f[i] == i)
            ans++;
    printf("%d", ans);
    return 0;
}